<?php

namespace App\Models\Dynamic;

use App\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class BloodDiet extends Model
{
    protected $table = "tn_blood_diet";

    public $timestamps = false;

    protected $fillable = [
        'dietsituation', 'dietpic', 'diettime', 'diettype', 'durationtime', 'userid', 'addtime', 'isdel'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function user()
    {
        return $this->hasMany(User::class);
    }

    /**
     * @param Builder $builder
     * @param $userid
     * @param $startTime
     * @param $endTime
     * @return mixed
     */
    public function scopeGetListUser(Builder $builder, $userid, $startTime, $endTime)
    {
        return $builder->whereUserid($userid)->whereBetween('diettime', [$startTime, $endTime]);
    }
}
